<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="books.storage.service.*"%>
<%@ page import="books.borrowing.entity.*"%>
<%@ page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1252" />
<title>ELibrary - Voir le catalogue</title>
<link rel="stylesheet" type="text/css" href="style.css" />

</head>
<body>
	<div id="wrap">

		<div class="header">
			<div class="logo">
				<a href="/ELibrary"><img src="images/logo.gif" alt="" title=""
					border="0" /></a>
			</div>
			<div id="menu">
				<ul>
					<li><a href="/ELibrary">Accueil</a></li>
					<li class="selected"><a href="/ELibrary/catalog">Consulter le catalogue</a></li>
					<% 
					SubscriberEntity user = (SubscriberEntity) session
					.getAttribute("user");
					if(user!=null) {
						out.println("<li><a href='/ELibrary/rent'>Voir mes emprunts</a></li>");
						out.println("<li><a href='/ELibrary/edit_profile'>Modifier mon profil</a></li>");
					}
					%>
				</ul>
			</div>
		</div>


		<div class="center_content">
			<div class="left_content">
				<%
					String search_field = (session.getAttribute("search_field")!=null) ? (String)session.getAttribute("search_field") : "";
				%>
				<form method="post" action="catalog">
				<h3>Chercher un livre par titre</h3>
				<input type="text" name="search_field" value="<%=search_field %>" />
				<input type="submit" value="Rechercher" />
				</form>
				<br/>
				<div class="new_products">
					<%
						List<BookDto> bookList = (List<BookDto>) session
								.getAttribute("bookList");

						for (BookDto book : bookList) {
							LiteraryGenreDto lgd = book.getLiterary();
							out.println("<div class='new_prod_box'>");
							out.println("<a href='#'>" + book.getTitle() + "<br/>de "
									+ book.getAuthor().getName() + "<br/><p style='font-size:12px;'>Catégorie : "+lgd.getWording()+"</p></a>");
							out.println("<div class='new_prod_bg'>");
							out.println("<a><img border='0' class='thumb' title='' alt='' src='images/books/"
									+ book.getIsbn() + ".jpg'></a>");
							if (user == null) {
								out.println("<p style='color:red; font-weight:bold;'>Connectez vous pour louer ce livre</p>");
							} else if (book.getCopiesNumber() < 1) {
								out.println("<p style='color:red; font-weight:bold;'>Ce livre n'est plus dispnonible</p>");
							} else {
								out.println("<form method='post' action='rent'>");
								out.println("<input type='hidden' name='user_action' value='rent_on' />");
								out.println("<input type='hidden' name='book_isbn' value='"
										+ book.getIsbn() + "' />");
								out.println("<input type='hidden' name='user_login' value='"
										+ user.getLogin() + "' />");
								out.println("<input type='submit' value='Louer ce livre'>");
								out.println("<p style='color:green; font-weight:bold;'>Encore "
										+ book.getCopiesNumber()
										+ " copies dispnonibles</p>");
								out.println("</form>");
							}
							out.println("</div>");
							out.println("</div>");
						}
					%>
				</div>


				<div class="clear"></div>
			</div>
			<!--end of left content-->

			<div class="right_content">

				<div class="right_box">

					<jsp:include page="login_form.jsp" />
				</div>


			</div>
			<div class="clear"></div>
		</div>
		<!--end of center content-->
		<div class="footer">
			<div class="left_footer">
				<img src="images/footer_logo.gif" alt="" title="" /><br /> <a
					href="http://csscreme.com/freecsstemplates/" title="free templates"><img
					src="images/csscreme.gif" alt="free templates"
					title="free templates" border="0" /></a>
			</div>
			<div class="right_footer">
				<a href="#">Accueil</a>

			</div>
		</div>
	</div>
</body>
</html>